#!/bin/bash
time1=$(date)
time2=$(date -d "$time1" +%s)
lasttime=`expr $time2 \* 1000`
firsttime=`expr $time2 \* 1000 - 259200000`

#echo $lasttime
#echo $firsttime

curl  -X POST "127.0.0.1:9211/chatdata/_delete_by_query?pretty" -H 'Content-Type:application/json' -d '
{
    "query": {
         "bool": {
              "must": [
                 {
                   "range": {
                      "msgtime": {
                          "lte": '$firsttime',
                          "format": "epoch_millis"
                         }
                    }
                }
              ],
              "must_not": []
         }
    }
}'